Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set title options #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mxstbr
Copy link

@mxstbr mxstbr commented Jan 25, 2019

I'm not sure if this is the right way to do it, but this adds another layer of function to add support for title options.

Closes #3

@@ -1,11 +1,11 @@
const title = require('title')
const visit = require('unist-util-visit')

module.exports = () => (tree, file) => {
module.exports = (options) => () => (tree, file) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it should be

module.exports = (options) => (tree, file) => {

no extra function needed

even though no one seems to notice this PR 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I patched node_modules locally and it appears Max's original solution works as intended! 🎉

Copy link
Member

@leerob leerob Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone in the future stumbling onto this, you can use patch-package to get this working.

@leerob
Copy link
Member

leerob commented Mar 19, 2020

I'd love to see this through 😍 I've been manually using title directly and was hoping to switch to a remark plugin.

Any chance we get some eyes here? 👀 @leo

Copy link
Member

@leerob leerob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing an approval into the abyss ✅

@flowsn4ke
Copy link

flowsn4ke commented Dec 9, 2020

Any updates on that? 🙃 I've tried messing around with the module itself like so,

const title = require('title')
const visit = require('unist-util-visit')

module.exports = (options) => (tree, file) => {
    visit(tree, 'heading', node => {
        visit(node, 'text', textNode => {
            const text = textNode.value ? textNode.value.trim() : ''
            textNode.value = title(text, {special: options})
        })
    })
}

but I can't figure out how to pass those options with the plugin when parsing markdown.... 😕 Also the patch-package link is broken, so no luck there either! Additionally, I peeked at @leerob's blog repo, but his workaround doesn't work on my project. Maybe because I'm using unified? I'm still relatively new to web development, so hopefully this makes sense!

@leerob
Copy link
Member

leerob commented Dec 9, 2020

@theophilelouvel I used the patch approach here since last May and just recently removed it. This plugin was nice, but ultimately I was tired of adding this to my exceptions list that I didn't want title capitalize.

@flowsn4ke
Copy link

flowsn4ke commented Dec 9, 2020

@theophilelouvel I used the patch approach here since last May and just recently removed it. This plugin was nice, but ultimately I was tired of adding this to my exceptions list that I didn't want title capitalize.

@leerob That's a drawback for sure... You can either spend time capitalizing or decapitalizing words 😅

It would be tempting to propose to bake a list of special cased words into title itself, but probably not too practical as the list would quickly get out of hands... !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support title options
4 participants